#include<iostream>
#include<string>
using namespace std;
const int N = 4e3 + 10;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		string s;
		cin >> s;
		int cnt = 0;
		int idx = 0;
		for (int i = s.size() - 1; i >= 0; i--) {
			if (s[i] == '0')cnt++;
			else {
				idx = i;
				break;
			}
		}
		cout << 10 - (s[idx] - '0');
		for (int i = 0; i < cnt; i++) {
			cout << 0;
		}
		cout << endl;
	}
	return 0;
}